package com.shiguiwu.springboot3.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @description: 认证对象
 * @author: stone
 * @date: Created by 2025/9/22 15:19
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.dto
 */
@Data
public class AuthUser implements UserDetails {

    private Long id;

    private String username;

    @JsonIgnore
    private String password;

    private String mobile;

    private Integer status = 1; // 默认状态为1(正常)

    private String avatarUrl;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    @Override
    public boolean isAccountNonLocked() {
        return this.status != null && this.status == 1;
    }
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
    @Override
    public boolean isEnabled() {
        return true;
    }
}
